package cn.com.bluemoon.daps.standard.vo;

import cn.com.bluemoon.daps.common.enums.StandardAuditStatus;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 数据变更列表数据实体
 *
 * @author Jarod Kong
 * @date 2020-08-08 11:25
 **/
@Data
@Accessors
@ApiModel(description = "数据变更列表数据实体")
public class StandardDataModifyVo implements Serializable {
    @ApiModelProperty(value = "流程id")
    private String processId;

    @ApiModelProperty(value = "标准类型 0 基础标准 1 指标标准")
    private Integer standardType;

    private String topicId;

    @ApiModelProperty(value = "主题")
    private String topicName;

    @ApiModelProperty(value = "一级分类id")
    private String category1;

    private String category2;

    private String category3;

    @ApiModelProperty(value = "一级分类")
    private String category1Name;

    @ApiModelProperty(value = "2级分类")
    private String category2Name;

    @ApiModelProperty(value = "3级分类")
    private String category3Name;

    @ApiModelProperty(value = "标准名称id")
    private String standardId;

    @ApiModelProperty(value = "标准名称")
    private String standardName;

    @ApiModelProperty(value = "标准英文名")
    private String standardEngName;

    @ApiModelProperty(value = "变更时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime modifyTime;

    @ApiModelProperty(value = "审批状态")
    private StandardAuditStatus modifyStatus;

    @ApiModelProperty(value = "变更类型")
    private Integer modifyType;

    @ApiModelProperty(value = "标准唯一id")
    private String standardUniqueId;

    @ApiModelProperty(value = "操作人, 对应流程创建者")
    private String creator;

    @ApiModelProperty(value = "操作人，对应流程处理这")
    private String operator;

    @ApiModelProperty("父类id")
    private String pid;

    @ApiModelProperty("叶子")
    private List<StandardDataModifyVo> children;

    @ApiModelProperty(value = "是否为标准最新版")
    private Boolean  publishNewest;

    @ApiModelProperty(value = "发布时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime publishTime;

    @ApiModelProperty("版本")
    private Integer version;

    @ApiModelProperty("tree 标题显示内容")
    private String treeTitle;

    /**
     * 根据当前实体返回tree标题
     * @return
     */
    @ApiModelProperty(hidden = true)
    public String getTreeTitleContent() {
        //noinspection AliControlFlowStatementWithoutBraces
        if (Boolean.FALSE.equals(getPublishNewest())) {
            return null;
        }
        return String.format("%s(%s)-当前版本%d-发布时间为%s-%s", this.getStandardName(), this.getStandardEngName(), getVersion(), getPublishTime().toString().replace("T", " "), getPublishNewest() ? "最新版" : "历史版");
    }
}
